package net.molchat.oauthorize.controller;


import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.farpost.spring.UrlBuilder;


/**
 * @author Valentine Markovich (vmarkovich@gorillagroup.com), Gorilla Inc.
 * 
 */
@Controller
public class LoginController {


//======================================================================= Fields
Logger log = Logger.getLogger(this.getClass());


//================================================================= loginProcess
/**
 * @param action
 *          Action string what to do ("login", "logout" etc)
 * @param model
 * @param request
 * @return View name
 */
@RequestMapping(value = "/login", params = "action")
public String loginProcess(@RequestParam("action") String action, Model model,
		HttpServletRequest request) {

	log.info("action = " + action);
	model.addAttribute("action", action);

	String locationUrl = UrlBuilder.build(request, HomeController.class, "#home")
			.asString();
	model.addAttribute("locationURL", locationUrl);

	return "redirect";
}


//==================================================================== loginShow
/**
 * @return View name
 */
@RequestMapping("/login")
public String loginShow() {


	return "login";
}


}
